<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="<?php echo STATIC_DOMAIN;?>css/reset.css" type="text/css" media="all"/>
<link rel="stylesheet" href="<?php echo STATIC_DOMAIN;?>css/buiding.css" type="text/css" media="all"/>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN;?>js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="<?php echo STATIC_DOMAIN;?>js/custom.js"></script>
</head>
<body>
	<div id="warp">
    	<div id="header">
        </div>
        <!-- end header-->
        <div id="content">
        	<div id="leftMenu">
            	<ul class="navi">
                	<li><a>Trang chủ</a></li>
                    <li><a>Giới thiệu</a></li>
                    <li><a>Hướng dẫn</a></li>
                    <li><a>Chat</a></li>
                    <li class="marbottom20"><a>Đăng nhập</a></li>
                    
                	<li><a>Forum</a></li>
                    <li><a>Cốt truyện</a></li>
                    <li><a>Trợ giúp</a></li>
                    <li><a>Liên hệ</a></li>
                    <li><a>Tìm hiểu</a></li>
                </ul>
            </div>
            <!-- end left menu-->
            <div id="viewInfo">
            	<div class="resource martop5 marleft20">
                	<table>
                    	<tr>
                        	<td width="80" title="Thịt">
								<span class="resFood"><?php echo $res['food'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                            
                            <td width="80" title="Gỗ">
								<span class="resWood"><?php echo $res['wood'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                            
                            <td width="80" title="Kim loại">
								<span class="resMetal"><?php echo $res['metal'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                            
                            <td width="80" title="Dầu mỏ">
								<span class="resPetro"><?php echo $res['petroleum'];?></span>/<?php echo $res['maxstore'];?>
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="infoBuild martop10 marleft20">
                    <table class="tbl-list marright5 float-left">
                        <tr>
                            <td colspan="4"><label>Gửi quân đội</label></td>
                        </tr>
                        <tr>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u2" name="u2" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u3" name="u3" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u4" name="u4" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u5" name="u5" type="text" size="6" value="" />
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u6" name="u6" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u7" name="u7" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u8" name="u8" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u9" name="u9" type="text" size="6" value="" />
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u10" name="u10" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u11" name="u11" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u12" name="u12" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u13" name="u13" type="text" size="6" value="" />
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u14" name="u14" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u15" name="u15" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u16" name="u16" type="text" size="6" value="" />
                                </p>
                            </td>
                            <td class="text-center">
                                <p>
                                    <input class="text-center" id="u17" name="u17" type="text" size="6" value="" />
                                </p>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" class="ver-middle text-right"><label>Tới tọa độ</label></td>
                            <td colspan="2" class="text-center">
                                <input class="text-center" id="root_x" name="root_x" type="text" size="4" value="" />
                                <input class="text-center" id="root_y" name="root_y" type="text" size="4" value="" />
                                <input type="hidden" id="xx" value="" />
                                <input type="hidden" id="yy" value="" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="4" class="text-center">
                                <input type="button" onclick="reviewSend();" value="Hiện lựa chọn" />
                            </td>
                        </tr>
                    </table>
                </div>
            </div>
            <div id="lstfield">
                <table class="tbl-list float-left" width="50%">
                    <thead>
                        <tr>
                            <th class="text-center">
                                Chọn một vị trí để gửi
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="text-center"></td>
                        </tr>
                    </tbody>
                </table>
            </div>
            
            <div>
                <a href="javascript:;" onclick="sendRES();">Gửi tài nguyên</a>
            </div>
            <!-- end view info-->
            <?php if($send_troop){?>
            <div class="infoBuild marbottom20 martop5 marleft20 padtop10 float-left">
                 <table class="tbl-list">
                    <thead>
                        <tr>
                            <td class="text-center" colspan="5">Các giao dịch</td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                        	<td class="text-center" class="bgr">Tài nguyên</td>
                            <td class="bgr">Thời gian</td>
                            <td class="bgr">Thời gian đến</td>
                        </tr>
                    	<?php
            				foreach($send as $lst)
            				{
            			?>
                    	<tr>
                            <td width="510" class="vera" style="text-align:left;color:#3B5998;font-weight:bold;"><?php echo $lst['id'];?></td>
                            <td width="120" class="vera">
                            	<div class="mk<?php echo $lst['id'];?> cl_rtime">
									<?php echo gmdate('H:i:s', $lst['rtime']);?>
                            	</div>
                            </td>
                            <td width="120" style="vertical-align:middle;">đến vào lúc
								<?php echo gmdate('H:i:s', $lst['timeend']).' ngày '.gmdate('d/m/Y', $lst['timeend']);?></td>
                            </tr>
                        <?php
                        	}
						?>
                    </tbody>
                </table>
             </div>
             <?php }?>
             <input type="hidden" id="coor" name="coor" value="<?php echo $coor;?>" />
        </div>
        <script>
            function sendRES()
            {
                var coor = $('#coor').val();
				var sfood = parseInt($('#spetro').val());
                var swood = parseInt($('#spetro').val());
				var smetal = parseInt($('#spetro').val());
                var spetro = parseInt($('#spetro').val());
                if(sfood==0 && swood==0 && smetal==0 && spetro==0)
                {
                    alert('vui long gui mot loai tai nguyen');
                    return;
                }
				var rootx = $('#root_x').val();
                var rooty = $('#root_y').val();
				var xx = $('#xx').val();
                var yy = $('#yy').val();
				var data = "sfood="+sfood+"&swood="+swood+"&smetal="+smetal+"&spetro="+spetro+"&rootx="+rootx+"&rooty="+rooty+"&xx="+xx+"&yy="+yy+"&coor="+coor; 
				$.ajax({
					 type: "GET",
					 url: '<?php echo STATIC_DOMAIN;?>market/send',
					 data: data,
					 success: function(result){
                        window.location.reload();
					 }
				 });
            }
			function reviewSend(){
				var rootx = $('#root_x').val();
                var rooty = $('#root_y').val();
                if(rootx=='' && rooty=='')
                {
                    alert('Hãy điền tọa độ muốn gửi tới.');
                    return;
                }
				var data = "rootx="+ rootx+"&rooty="+ rooty; 
				$.ajax({
					 type: "GET",
					 url: '<?php echo STATIC_DOMAIN;?>market/review_coor_send',
					 data: data,
					 success: function(result){
                        if(result!='NULL')
                        {
                            $('#lstfield').html(result);
                        }
					 }
				 });	
			}
            function pushIn(xx, yy)
            {
				$('#xx').val(xx);
                $('#yy').val(yy);
            }
			numberUp('.resFood', <?php echo $res['food'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rtf;?>);
			numberUp('.resWood', <?php echo $res['wood'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rtw;?>);
			numberUp('.resMetal', <?php echo $res['metal'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rtm;?>);
			numberUp('.resPetro', <?php echo $res['petroleum'];?>, 1, <?php echo $res['maxstore'];?>, <?php echo $rtp;?>);
            <?php
                if($send_troop)
                {
				    foreach($infoSend as $r){
					   echo "ww_timer('".gmdate('H:i:s', $r['rtime'])."', 'mk".$r['id']."');";
				    }
                }
			?>
		</script>
        <!-- end content-->
        <div id="footer">
        </div>
        <!-- end footer-->
    </div>
</body>
</html>